﻿@{
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<html>
    <head>
        <script type="text/javascript">
            function editFC(opType) {
                var row = $('#dg').datagrid('getSelected');
                var msg, url, hint;
                if (opType == "Close") {
                    msg = "Are you sure you want to close this fake comment?";
                    url = '/PromotionComment/CloseFC';
                    hint = 'Close Successfully';
                }
                else {
                    msg = "Are you sure you want to remove this fake comment?";
                    url = '/PromotionComment/DeleteFC';
                    hint = 'Delete Successfully';
                }
                if (row) {
                    $.messager.confirm('Confirm', msg, function (r) {
                        if (r) {
                            $.post(url, { id: row.FakeCommentId }, function (result) {
                                if (result == "success") {
                                    $.messager.alert("Message", hint);
                                    $('#dg').datagrid('reload');
                                } else {
                                    $.messager.show({    // show error message
                                        title: 'Error',
                                        msg: 'Please contact the admin for support'
                                    });
                                }
                            }, 'text');
                        }
                    });
                }
                else {
                    $.messager.alert("Message", "Please select one record.");
                }
            }
            function searchFC() {
                $('#dg').datagrid('load', {
                    FCStatus: $('#fcStatus').combobox('getValue')
                });
            }
        </script>
    </head>
    <body>
        <table id="dg" title="Fake Comment" class="easyui-datagrid" style="height:500px"
                url="/PromotionComment/GetAllFC"
                toolbar="#toolbar" pagination="true" iconCls="icon-ok"
                rownumbers="true" fitColumns="true" singleSelect="true">
            <thead>
                <tr>
                    <th field="FakeCommentId" width="50" hidden="true">PaymentId</th>
                    <th field="CommentBody" width="50">Comment</th>
                    <th field="CommentUser" width="50">Comment User</th>
                    <th field="PromotionName" width="50">Promotion</th>
                    <th field="CreateDate" formatter="ToJavaScriptDate" width="50">CreateDate</th>
                    <th field="CloseDate" formatter="ToJavaScriptDate" width="50">CloseDate</th>
                </tr>
            </thead>
        </table>        
        <div id="toolbar">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editFC('Close')">Close FC</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="editFC('Delete')">Remove FC</a>
            <div style="margin-left: 10px">
                Status:
                <select class="easyui-combobox" id="fcStatus" name="fcStatus" style="width:100px;">
                    <option value="All">All</option>
                    <option value="Open">Open</option>
                    <option value="Closed">Closed</option>
                </select>
                <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="searchFC()">Search</a>
        </div>
        </div>
    </body>
</html>